define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/sale/index' + location.search,
                    // add_url: 'order/sale/add',
                    edit_url: 'order/sale/edit',
                    // del_url: 'order/sale/del',
                    multi_url: 'order/sale/multi',
                    import_url: 'order/sale/import',
                    table: 'order_sale',
                }
            });

            var table = $("#table");
            $(document).on('click','.shows',function (){
                console.log(111);
                var url = $(this).attr('data-url');
                var msg = '查看详情';
                var width  = $(this).attr('data-width');
                var height = $(this).attr('data-height');
                var area   = [$(window).width() > 1000 ? (width?width:'100%') : '100%', $(window).height() > 600 ? (height?height:'100%') : '100%'];
                options = {
                    shadeClose: false,
                    area : area,
                };
                // Fast.api.open(url,msg,options);
            })


            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            $(".layer-close").click(function () {
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                console.log(index)
                parent.layer.close(index); //再执行关闭
            })
            Controller.api.bindevent();
        },
        refused: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
